home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / MetalLookAndFeel.java < prev    next >
Text File  |  1998-06-30  |  33KB  |  665 lines

  1. /*   
  2.  * @(#)MetalLookAndFeel.java    1.70 98/04/14
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. package com.sun.java.swing.plaf.metal;
  22.  
  23. import java.awt.*;
  24. import com.sun.java.swing.plaf.*;
  25. import com.sun.java.swing.*;
  26. import com.sun.java.swing.plaf.basic.*;
  27. import com.sun.java.swing.border.*;
  28. import com.sun.java.swing.text.JTextComponent;
  29. import com.sun.java.swing.text.DefaultEditorKit;
  30.  
  31. import java.awt.Font;
  32. import java.awt.Color;
  33. import java.awt.SystemColor;
  34. import java.awt.event.KeyEvent;
  35. import java.awt.event.InputEvent;
  36.  
  37. import java.net.URL;
  38. import java.io.Serializable;
  39.  
  40.  
  41. /**
  42.  * Implements The Metal Look and Feel.
  43.  * <p>
  44.  * For the keyboard keys defined for each component in this Look and
  45.  * Feel (L&F), see 
  46.  * <a href="../../doc-files/Key-Metal.html">Component Keystroke Actions for the Metal L&F</a>.
  47.  * <p>
  48.  * Warning: serialized objects of this class will not be compatible with
  49.  * future swing releases.  The current serialization support is appropriate
  50.  * for short term storage or RMI between Swing1.0 applications.  It will
  51.  * not be possible to load serialized Swing1.0 objects with future releases
  52.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  53.  * baseline for the serialized form of Swing objects.
  54.  *
  55.  * @version 1.70 04/14/98
  56.  * @author Steve Wilson
  57.  */
  58. public class MetalLookAndFeel extends BasicLookAndFeel
  59. {
  60.   
  61.     private static MetalTheme currentTheme;
  62.  
  63.     public String getName() {
  64.         return "Metal";
  65.     }
  66.  
  67.     public String getID() {
  68.         return "Metal";
  69.     }
  70.  
  71.     public String getDescription() {
  72.         return "The Metal Look and Feel";
  73.     }
  74.  
  75.     
  76.     public boolean isNativeLookAndFeel() {
  77.         return false;
  78.     }
  79.  
  80.  
  81.     public boolean isSupportedLookAndFeel() {
  82.         return true;
  83.     }
  84.     
  85.     /** 
  86.      * Initialize the uiClassID to BasicComponentUI mapping.
  87.      * The JComponent classes define their own uiClassID constants
  88.      * (see AbstractComponent.getUIClassID).  This table must
  89.      * map those constants to a BasicComponentUI class of the
  90.      * appropriate type.
  91.      * 
  92.      * @see BasicLookAndFeel#getDefaults
  93.      */
  94.     protected void initClassDefaults(UIDefaults table)
  95.     {
  96.         String basicPackageName = "com.sun.java.swing.plaf.basic.";
  97.         String metalPackageName = "com.sun.java.swing.plaf.metal.";
  98.  
  99.         Object[] uiDefaults = {
  100.                    "ButtonUI", metalPackageName + "MetalButtonUI",
  101.                  "CheckBoxUI", metalPackageName + "MetalCheckBoxUI",
  102.              "ColorChooserUI", basicPackageName + "BasicColorChooserUI",
  103.                   "MenuBarUI", basicPackageName + "BasicMenuBarUI",
  104.                      "MenuUI", basicPackageName + "BasicMenuUI",
  105.                  "MenuItemUI", basicPackageName + "BasicMenuItemUI",
  106.          "CheckBoxMenuItemUI", basicPackageName + "BasicCheckBoxMenuItemUI",
  107.       "RadioButtonMenuItemUI", basicPackageName + "BasicRadioButtonMenuItemUI",
  108.               "RadioButtonUI", metalPackageName + "MetalRadioButtonUI",
  109.              "ToggleButtonUI", metalPackageName + "MetalToggleButtonUI",
  110.                 "PopupMenuUI", basicPackageName + "BasicPopupMenuUI",
  111.               "ProgressBarUI", metalPackageName + "MetalProgressBarUI",
  112.                 "ScrollBarUI", metalPackageName + "MetalScrollBarUI",
  113.                "ScrollPaneUI", metalPackageName + "MetalScrollPaneUI",
  114.                 "SplitPaneUI", metalPackageName + "MetalSplitPaneUI",
  115.                    "SliderUI", metalPackageName + "MetalSliderUI",
  116.                   "SpinnerUI", basicPackageName + "BasicSpinnerUI",
  117.                 "SeparatorUI", metalPackageName + "MetalSeparatorUI",
  118.                "TabbedPaneUI", metalPackageName + "MetalTabbedPaneUI",
  119.                  "TextAreaUI", basicPackageName + "BasicTextAreaUI",
  120.                 "TextFieldUI", metalPackageName + "MetalTextFieldUI",
  121.             "PasswordFieldUI", basicPackageName + "BasicPasswordFieldUI",
  122.                  "TextPaneUI", basicPackageName + "BasicTextPaneUI",
  123.                "EditorPaneUI", basicPackageName + "BasicEditorPaneUI",
  124.                      "TreeUI", metalPackageName + "MetalTreeUI",
  125.                     "LabelUI", metalPackageName + "MetalLabelUI",
  126.                      "ListUI", basicPackageName + "BasicListUI",
  127.                   "ToolBarUI", metalPackageName + "MetalToolBarUI",
  128.                   "ToolTipUI", metalPackageName + "MetalToolTipUI",
  129.                  "ComboBoxUI", metalPackageName + "MetalComboBoxUI",
  130.                     "TableUI", basicPackageName + "BasicTableUI",
  131.               "TableHeaderUI", basicPackageName + "BasicTableHeaderUI",
  132.             "InternalFrameUI", metalPackageName + "MetalInternalFrameUI",
  133.            "StandardDialogUI", basicPackageName + "BasicStandardDialogUI",
  134.               "DesktopPaneUI", basicPackageName + "BasicDesktopPaneUI",
  135.               "DesktopIconUI", metalPackageName + "MetalDesktopIconUI",
  136.               "FileChooserUI", metalPackageName + "MetalFileChooserUI",
  137.                "OptionPaneUI", basicPackageName + "BasicOptionPaneUI"
  138.         };
  139.  
  140.         table.putDefaults(uiDefaults);
  141.     }
  142.  
  143.     /**
  144.      * Load the SystemColors into the defaults table.  The keys
  145.      * for SystemColor defaults are the same as the names of
  146.      * the public fields in SystemColor.
  147.      */
  148.     protected void initSystemColorDefaults(UIDefaults table)
  149.     {
  150.         Object[] systemColors = {
  151.                 "desktop", getDesktopColor(), /* Color of the desktop background */
  152.           "activeCaption", getWindowTitleBackground(), /* Color for captions (title bars) when they are active. */
  153.       "activeCaptionText", getWindowTitleForeground(), /* Text color for text in captions (title bars). */
  154.     "activeCaptionBorder", getPrimaryControlShadow(), /* Border color for caption (title bar) window borders. */
  155.         "inactiveCaption", getWindowTitleInactiveBackground(), /* Color for captions (title bars) when not active. */
  156.     "inactiveCaptionText", getWindowTitleInactiveForeground(), /* Text color for text in inactive captions (title bars). */
  157.   "inactiveCaptionBorder", getControlShadow(), /* Border color for inactive caption (title bar) window borders. */
  158.                  "window", getWindowBackground(), /* Default color for the interior of windows */
  159.            "windowBorder", getControl(), /* ??? */
  160.              "windowText", getUserTextColor(), /* ??? */
  161.                    "menu", getMenuBackground(), /* Background color for menus */
  162.                "menuText", getMenuForeground(), /* Text color for menus  */
  163.                    "text", getWindowBackground(), /* Text background color */
  164.                "textText", getUserTextColor(), /* Text foreground color */
  165.           "textHighlight", getTextHighlightColor(), /* Text background color when selected */
  166.       "textHighlightText", getHighlightedTextColor(), /* Text color when selected */
  167.        "textInactiveText", getInactiveSystemTextColor(), /* Text color when disabled */
  168.                 "control", getControl(), /* Default color for controls (buttons, sliders, etc) */
  169.             "controlText", getControlTextColor(), /* Default color for text in controls */
  170.        "controlHighlight", getControlHighlight(), /* Specular highlight (opposite of the shadow) */
  171.      "controlLtHighlight", getControlHighlight(), /* Highlight color for controls */
  172.           "controlShadow", getControlShadow(), /* Shadow color for controls */
  173.         "controlDkShadow", getControlDarkShadow(), /* Dark shadow color for controls */
  174.               "scrollbar", getControl(), /* Scrollbar background (usually the "track") */
  175.                    "info", getPrimaryControl(), /* ToolTip Background */
  176.                "infoText", getPrimaryControlInfo()  /* ToolTip Text */
  177.         };
  178.  
  179.         for(int i = 0; i < systemColors.length; i += 2) {
  180.             table.put((String)systemColors[i], systemColors[i + 1]);
  181.         }
  182.     }
  183.  
  184.     protected void initComponentDefaults(UIDefaults table) {
  185.         super.initComponentDefaults( table );
  186.  
  187.     Object fieldTextBorder = new BorderUIResource( new CompoundBorder(
  188.                                new MetalTextFieldUI.TextFieldBorder(),
  189.                                    BasicMarginBorder.getMarginBorder()));
  190.  
  191.  
  192.         Object textBorder = new BorderUIResource( new CompoundBorder(
  193.                                                        new Flush3DBorder(),
  194.                                                        BasicMarginBorder.getMarginBorder()));
  195.  
  196.     JTextComponent.KeyBinding[] fieldBindings = {
  197.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_C, 
  198.                                  InputEvent.CTRL_MASK),
  199.                       DefaultEditorKit.copyAction),
  200.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_V, 
  201.                                  InputEvent.CTRL_MASK),
  202.                       DefaultEditorKit.pasteAction),
  203.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_X, 
  204.                                  InputEvent.CTRL_MASK),
  205.                       DefaultEditorKit.cutAction),
  206.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 
  207.                                  InputEvent.SHIFT_MASK),
  208.                       DefaultEditorKit.selectionBackwardAction),
  209.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 
  210.                                  InputEvent.SHIFT_MASK),
  211.                       DefaultEditorKit.selectionForwardAction),
  212.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 
  213.                                  InputEvent.CTRL_MASK),
  214.                       DefaultEditorKit.previousWordAction),
  215.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 
  216.                                  InputEvent.CTRL_MASK),
  217.                       DefaultEditorKit.nextWordAction),
  218.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 
  219.                                  InputEvent.CTRL_MASK | 
  220.                                  InputEvent.SHIFT_MASK),
  221.                       DefaultEditorKit.selectionPreviousWordAction),
  222.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 
  223.                                  InputEvent.CTRL_MASK |
  224.                                  InputEvent.SHIFT_MASK),
  225.                       DefaultEditorKit.selectionNextWordAction),
  226.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_A, 
  227.                                  InputEvent.CTRL_MASK),
  228.                       DefaultEditorKit.selectAllAction),
  229.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0),
  230.                       DefaultEditorKit.beginLineAction),
  231.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0),
  232.                       DefaultEditorKit.endLineAction),
  233.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 
  234.                                  InputEvent.SHIFT_MASK),
  235.                       DefaultEditorKit.selectionBeginLineAction),
  236.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_END, 
  237.                                  InputEvent.SHIFT_MASK),
  238.                       DefaultEditorKit.selectionEndLineAction),
  239.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
  240.                       JTextField.notifyAction)
  241.     };
  242.  
  243.     JTextComponent.KeyBinding[] multilineBindings = {
  244.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_C, 
  245.                                  InputEvent.CTRL_MASK),
  246.                       DefaultEditorKit.copyAction),
  247.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_V, 
  248.                                  InputEvent.CTRL_MASK),
  249.                       DefaultEditorKit.pasteAction),
  250.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_X, 
  251.                                  InputEvent.CTRL_MASK),
  252.                       DefaultEditorKit.cutAction),
  253.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 
  254.                                  InputEvent.SHIFT_MASK),
  255.                       DefaultEditorKit.selectionBackwardAction),
  256.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 
  257.                                  InputEvent.SHIFT_MASK),
  258.                       DefaultEditorKit.selectionForwardAction),
  259.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 
  260.                                  InputEvent.CTRL_MASK),
  261.                       DefaultEditorKit.previousWordAction),
  262.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 
  263.                                  InputEvent.CTRL_MASK),
  264.                       DefaultEditorKit.nextWordAction),
  265.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 
  266.                                  InputEvent.CTRL_MASK | 
  267.                                  InputEvent.SHIFT_MASK),
  268.                       DefaultEditorKit.selectionPreviousWordAction),
  269.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 
  270.                                  InputEvent.CTRL_MASK |
  271.                                  InputEvent.SHIFT_MASK),
  272.                       DefaultEditorKit.selectionNextWordAction),
  273.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_A, 
  274.                                  InputEvent.CTRL_MASK),
  275.                       DefaultEditorKit.selectAllAction),
  276.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0),
  277.                       DefaultEditorKit.beginLineAction),
  278.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0),
  279.                       DefaultEditorKit.endLineAction),
  280.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 
  281.                                  InputEvent.SHIFT_MASK),
  282.                       DefaultEditorKit.selectionBeginLineAction),
  283.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_END, 
  284.                                  InputEvent.SHIFT_MASK),
  285.                       DefaultEditorKit.selectionEndLineAction),
  286.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0),
  287.                       DefaultEditorKit.upAction),
  288.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0),
  289.                       DefaultEditorKit.downAction),
  290.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0),
  291.                       DefaultEditorKit.pageUpAction),
  292.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0),
  293.                       DefaultEditorKit.pageDownAction),
  294.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_UP,
  295.                                  InputEvent.SHIFT_MASK),
  296.                       DefaultEditorKit.selectionUpAction),
  297.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN,
  298.                                  InputEvent.SHIFT_MASK),
  299.                       DefaultEditorKit.selectionDownAction),
  300.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
  301.                       DefaultEditorKit.insertBreakAction),
  302.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0),
  303.                       DefaultEditorKit.insertTabAction)
  304.     };
  305.  
  306.         Object scrollPaneBorder = new BorderUIResource( new MetalScrollPaneUI.ScrollPaneBorder() );
  307.  
  308.         Object buttonBorder =  new BorderUIResource(new CompoundBorder(
  309.                                            new MetalButtonBorder(),
  310.                                            BasicMarginBorder.getMarginBorder()));
  311.  
  312.         Object toggleButtonBorder =  new BorderUIResource(new CompoundBorder(
  313.                                       new MetalToggleButtonUI.MetalToggleButtonBorder(),
  314.                                       BasicMarginBorder.getMarginBorder()));
  315.  
  316.         Object comboBoxEditorActiveValue  = new UIDefaults.ActiveValue() {
  317.             public Object createValue(UIDefaults table) {
  318.                 return new MetalComboBoxEditor.UIResource();
  319.             }
  320.         };
  321.  
  322.         Object titledBorderBorder = new BorderUIResource(new LineBorder(table.getColor("controlShadow")));
  323.  
  324.         Object desktopIconBorder = new BorderUIResource(new CompoundBorder(
  325.                                       new LineBorder(getControlDarkShadow(), 1),
  326.                                       new MatteBorder (2,2,1,2, getControl())));
  327.      
  328.         Object internalFrameBorder = new BorderUIResource( new MetalInternalFrameBorder() );
  329.  
  330.         Object menuBarBorder = new BorderUIResource( new MetalMenuBarBorder() );
  331.         Object popupMenuBorder = new BorderUIResource( new MetalPopupMenuBorder() );
  332.         Object menuItemBorder = new BorderUIResource( new MetalMenuItemBorder() );
  333.         Object toolBarBorder = new BorderUIResource( new MetalToolBarBorder() );
  334.  
  335.     Object progressBarBorder = new BorderUIResource(
  336.         new LineBorder(getControlDarkShadow(), 1));
  337.  
  338.         Object focusCellHighlightBorder = new BorderUIResource( 
  339.                                               new LineBorder(getFocusColor()) );
  340.  
  341.         //
  342.         // DEFAULTS TABLE
  343.         //
  344.  
  345.     final int internalFrameIconSize = 12;
  346.  
  347.         Object[] defaults = {
  348.             // Text (Note: many are inherited)
  349.             "TextField.border", fieldTextBorder,
  350.         "TextField.font", getUserTextFont(),
  351.         "TextField.caretForeground", getUserTextColor(),
  352.  
  353.             "PasswordField.border", textBorder,
  354.             "PasswordField.font", getUserTextFont(),
  355.         "PasswordField.caretForeground", getUserTextColor(),
  356.  
  357.             "TextArea.border", textBorder,
  358.             "TextArea.font", getUserTextFont(),
  359.             "TextArea.caretForeground", getUserTextColor(),
  360.  
  361.             "TextPane.border", textBorder,
  362.             "TextPane.font", getUserTextFont(),
  363.             "TextPane.caretForeground", getUserTextColor(),
  364.  
  365.             "EditorPane.border", BasicMarginBorder.getMarginBorder(),
  366.  
  367.         "TextField.keyBindings", fieldBindings,
  368.         "PasswordField.keyBindings", fieldBindings,
  369.         "TextArea.keyBindings", multilineBindings,
  370.         "TextPane.keyBindings", multilineBindings,
  371.         "EditorPane.keyBindings", multilineBindings,
  372.             
  373.             // CheckBox
  374.             "CheckBox.icon", new MetalCheckBoxIcon(),
  375.             "CheckBox.font", getControlTextFont(),
  376.             "CheckBox.focus", getFocusColor(),
  377.  
  378.             // Button
  379.             "Button.background", getControl(),
  380.             "Button.foreground", getControlTextColor(),
  381.             "Button.pressed", getControlShadow(),
  382.             "Button.disabledText", getInactiveControlTextColor(),
  383.             "Button.disabled", getControl(),
  384.             "Button.border", buttonBorder,
  385.             "Button.font", getControlTextFont(),
  386.             "Button.focus", getFocusColor(),
  387.  
  388.             // File View 
  389.             "FileView.directoryIcon", MetalIconFactory.getTreeFolderIcon(),
  390.             "FileView.fileIcon", MetalIconFactory.getTreeLeafIcon(),
  391.             "FileView.computerIcon", MetalIconFactory.getTreeComputerIcon(),
  392.             "FileView.hardDriveIcon", MetalIconFactory.getTreeHardDriveIcon(),
  393.             "FileView.floppyDriveIcon", MetalIconFactory.getTreeFloppyDriveIcon(),
  394.  
  395.             // File Chooser
  396.             "FileChooser.detailsViewIcon", MetalIconFactory.getFileChooserDetailViewIcon(),
  397.             "FileChooser.homeFolderIcon", MetalIconFactory.getFileChooserHomeFolderIcon(),
  398.             "FileChooser.listViewIcon", MetalIconFactory.getFileChooserListViewIcon(),
  399.             "FileChooser.newFolderIcon", MetalIconFactory.getFileChooserNewFolderIcon(),
  400.             "FileChooser.upFolderIcon", MetalIconFactory.getFileChooserUpFolderIcon(),
  401.  
  402.             // InternalFrame
  403.             "InternalFrameTitlePane.closeIcon", MetalIconFactory.getInternalFrameCloseIcon(internalFrameIconSize),
  404.             "InternalFrameTitlePane.maximizeIcon", MetalIconFactory.getInternalFrameMaximizeIcon(internalFrameIconSize),
  405.             "InternalFrameTitlePane.iconizeIcon", MetalIconFactory.getInternalFrameMinimizeIcon(internalFrameIconSize),
  406.             "InternalFrameTitlePane.altMaximizeIcon", MetalIconFactory.getInternalFrameAltMaximizeIcon(internalFrameIconSize),
  407.             "InternalFrameTitlePane.font",  getWindowTitleFont(),
  408.  
  409.             // RadioButton
  410.             "RadioButton.icon", MetalIconFactory.getRadioButtonIcon(),
  411.             "RadioButton.font", getControlTextFont(),
  412.             "RadioButton.focus", getFocusColor(),
  413.  
  414.             // ToolTip
  415.             "ToolTip.font", getSystemTextFont(),
  416.             "ToolTip.border", new LineBorder(getPrimaryControlDarkShadow()),
  417.             "ToolTip.background", table.get("info"),
  418.             "ToolTip.foreground", table.get("infoText"),
  419.  
  420.             // Toggle Button Defaults
  421.             "ToggleButton.background", getControl(),
  422.             "ToggleButton.foreground", getControlTextColor(),
  423.             "ToggleButton.pressed", getControlShadow(),
  424.             "ToggleButton.selected", getControlShadow(),
  425.             "ToggleButton.disabledText", getInactiveControlTextColor(),
  426.             "ToggleButton.disabledSelectedText", getControlDarkShadow(),
  427.             "ToggleButton.disabledBackground", getControl(),
  428.             "ToggleButton.disabledSelectedBackground", getControlShadow(),
  429.             "ToggleButton.focus", getFocusColor(),
  430.             "ToggleButton.border", toggleButtonBorder,
  431.             "ToggleButton.font", getControlTextFont(),
  432.  
  433.             // Slider Defaults
  434.             "Slider.border", null,
  435.             "Slider.foreground", getPrimaryControlShadow(),
  436.             "Slider.background", getControl(),
  437.             "Slider.focus", getFocusColor(),
  438.             "Slider.trackWidth", new Integer( 9 ),
  439.             "Slider.majorTickLength", new Integer( 6 ),
  440.             "Slider.horizontalThumbIcon", MetalIconFactory.getHorizontalSliderThumbIcon(),
  441.             "Slider.verticalThumbIcon", MetalIconFactory.getVerticalSliderThumbIcon(),
  442.  
  443.             // Progress Bar
  444.             "ProgressBar.foreground", getPrimaryControlShadow(), 
  445.             "ProgressBar.background", getControl(),
  446.             "ProgressBar.foregroundHighlight", getPrimaryControlShadow(), 
  447.             "ProgressBar.backgroundHighlight", getControl(),
  448.         "ProgressBar.border", progressBarBorder,
  449.             "ProgressBar.cellSpacing", new Integer(0),
  450.             "ProgressBar.cellLength", new Integer(1),
  451.  
  452.             // Combo Box
  453.             "ComboBox.background", table.get("control"),
  454.             "ComboBox.foreground", table.get("controlText"),
  455.             "ComboBox.selectedBackground", getPrimaryControlShadow(),
  456.             "ComboBox.selectedForeground", getControlTextColor(),
  457.             "ComboBox.listBackground", getControl(),
  458.             "ComboBox.listForeground", getControlTextColor(),
  459.             "ComboBox.font", getControlTextFont(),
  460.             "ComboBox.editor", comboBoxEditorActiveValue,
  461.  
  462.             // Internal Frame Defaults
  463.             "InternalFrame.icon", MetalIconFactory.getInternalFrameDefaultMenuIcon(),
  464.             "InternalFrame.border", internalFrameBorder,
  465.  
  466.             // Desktop Icon
  467.             "DesktopIcon.border", desktopIconBorder,
  468.             "DesktopIcon.font", getControlTextFont(),
  469.             "DesktopIcon.foreground", getControlTextColor(),
  470.             "DesktopIcon.background", getControl(),
  471.  
  472.             // Titled Border
  473.             "TitledBorder.font", getControlTextFont(),
  474.             "TitledBorder.titleColor", getSystemTextColor(),
  475.             "TitledBorder.border", titledBorderBorder,
  476.  
  477.             // Label
  478.             "Label.font", getControlTextFont(),
  479.             "Label.background", table.get("control"),
  480.             "Label.foreground", getSystemTextColor(),
  481.             "Label.disabled", getInactiveSystemTextColor(),
  482.  
  483.             // List
  484.             "List.focusCellHighlightBorder", focusCellHighlightBorder,
  485.  
  486.             // ScrollBar
  487.             "ScrollBar.background", getControl(),
  488.             "ScrollBar.highlight", getControlHighlight(),
  489.             "ScrollBar.shadow", getControlDarkShadow(),
  490.             "ScrollBar.thumb", getPrimaryControlShadow(),
  491.             "ScrollBar.thumbShadow", getPrimaryControlDarkShadow(),
  492.             "ScrollBar.thumbHighlight", getPrimaryControl(),
  493.             "ScrollBar.width", new Integer( 17 ),
  494.  
  495.         // ScrollPane
  496.         "ScrollPane.border", scrollPaneBorder,
  497.         "ScrollPane.background", table.get("window"),
  498.  
  499.             // Tabbed Pane
  500.             "TabbedPane.font", getControlTextFont(),
  501.             "TabbedPane.tabBackground", getControl(),
  502.             "TabbedPane.tabForeground", getControlTextColor(),
  503.             "TabbedPane.tabHighlight", getControlHighlight(),
  504.             "TabbedPane.tabDarkShadow", getControlDarkShadow(),
  505.             "TabbedPane.focus", getPrimaryControlDarkShadow(),
  506.             "TabbedPane.selected", getPrimaryControlShadow(),
  507.             "TabbedPane.selectHighlight", getPrimaryControl(),
  508.             
  509.             // Table
  510.             "Table.focusCellHighlightBorder", focusCellHighlightBorder,
  511.             "Table.focusCellBackground", getFocusColor(),
  512.             "Table.scrollPaneBorder", scrollPaneBorder,
  513.               "Table.gridColor", getControlShadow(),  // grid line color
  514.  
  515.         "TableHeader.cellBorder", new MetalUtils.TableHeaderBorder(),
  516.  
  517.             // MenuBar
  518.             "MenuBar.border", menuBarBorder,
  519.             "MenuBar.font", getMenuTextFont(),
  520.             "MenuBar.foreground", getMenuForeground(),
  521.             "MenuBar.background", getMenuBackground(),
  522.  
  523.             // Menu
  524.             "Menu.border", menuItemBorder,
  525.             "Menu.font", getMenuTextFont(),
  526.             "Menu.foreground", getMenuForeground(),
  527.             "Menu.background", getMenuBackground(),
  528.             "Menu.pressedForeground", getMenuSelectedForeground(),
  529.             "Menu.pressedBackground", getMenuSelectedBackground(),
  530.             "Menu.arrowIcon", MetalIconFactory.getMenuArrowIcon(),
  531.  
  532.             // Menu Item
  533.             "MenuItem.border", menuItemBorder,
  534.             "MenuItem.borderPainted", Boolean.TRUE,
  535.             "MenuItem.font", getMenuTextFont(),
  536.             "MenuItem.acceleratorFont", getSubTextFont(),
  537.             "MenuItem.acceleratorForeground", getAcceleratorForeground(),
  538.             "MenuItem.acceleratorPressedForeground", getAcceleratorSelectedForeground(),
  539.             "MenuItem.foreground", getMenuForeground(),
  540.             "MenuItem.background", getMenuBackground(),
  541.             "MenuItem.pressedForeground", getMenuSelectedForeground(),
  542.             "MenuItem.pressedBackground", getMenuSelectedBackground(),
  543.             "MenuItem.disabledForeground", getMenuDisabledForeground(),
  544.             "MenuItem.acceleratorFont", getSubTextFont(),
  545.             "MenuItem.acceleratorForeground", getAcceleratorForeground(),
  546.             "MenuItem.acceleratorPressedForeground", getAcceleratorSelectedForeground(),
  547.             "MenuItem.checkIcon", MetalIconFactory.getMenuItemCheckIcon(),
  548.             "MenuItem.arrowIcon", MetalIconFactory.getMenuItemArrowIcon(),
  549.  
  550.             // Separator
  551.             "Separator.background", getSeparatorBackground(),
  552.             "Separator.foreground", getSeparatorForeground(),
  553.  
  554.             // Popup Menu
  555.             "PopupMenu.background", getMenuBackground(),
  556.             "PopupMenu.border", popupMenuBorder,          
  557.  
  558.             // CB & RB Menu Item
  559.             "CheckBoxMenuItem.icon", MetalIconFactory.getCheckBoxMenuItemIcon(),
  560.             "RadioButtonMenuItem.icon", MetalIconFactory.getRadioButtonMenuItemIcon(),
  561.  
  562.         // SplitPane
  563.  
  564.         "SplitPane.dividerSize", new Integer(8),
  565.  
  566.             // Tree
  567.             "Tree.background", getWindowBackground(),
  568.         "Tree.font", getSystemTextFont(),
  569.             "Tree.textSelectionColor", table.get("textHighlightText"),
  570.             "Tree.textNonSelectionColor", table.get("textText"),
  571.             "Tree.borderSelectionColor", getWindowBackground(),
  572.             "Tree.backgroundSelectionColor", table.get("textHighlight"),
  573.             "Tree.backgroundNonSelectionColor", getWindowBackground(),
  574.             "Tree.openIcon", MetalIconFactory.getTreeFolderIcon(),
  575.             "Tree.closedIcon", MetalIconFactory.getTreeFolderIcon(),
  576.             "Tree.leafIcon", MetalIconFactory.getTreeLeafIcon(),
  577.             "Tree.expandedIcon", MetalIconFactory.getTreeControlIcon( MetalIconFactory.DARK ),
  578.             "Tree.collapsedIcon", MetalIconFactory.getTreeControlIcon( MetalIconFactory.LIGHT ),
  579.             "Tree.line", getPrimaryControl(), // horiz lines
  580.             "Tree.hash", getPrimaryControl(),  // legs
  581.  
  582.             // ToolBar
  583.             "ToolBar.border", toolBarBorder,
  584.             "ToolBar.background", getMenuBackground(),
  585.             "ToolBar.foreground", getMenuForeground(),
  586.             "ToolBar.font", getMenuTextFont(),
  587.             "ToolBar.dockingColor", getMenuBackground(),
  588.             "ToolBar.floatingColor", getMenuBackground(),
  589.             "ToolBar.dockingBorderColor", getPrimaryControlDarkShadow(), 
  590.             "ToolBar.floatingBorderColor", getPrimaryControl(),
  591.         };
  592.  
  593.         table.putDefaults(defaults);
  594.     }
  595.  
  596.     protected void createDefaultTheme() {
  597.         if( currentTheme == null) 
  598.         currentTheme =  new DefaultMetalTheme();
  599.     }
  600.  
  601.     public UIDefaults getDefaults() {
  602.         createDefaultTheme();
  603.         UIDefaults table = super.getDefaults();
  604.         currentTheme.addCustomEntriesToTable(table);
  605.         return table;
  606.     }
  607.  
  608.     public static void setCurrentTheme(MetalTheme theme) {
  609.         if (theme == null) {
  610.             throw new NullPointerException("Can't have null theme");
  611.         }
  612.         currentTheme = theme;
  613.     }
  614.  
  615.     public static FontUIResource getControlTextFont() { return currentTheme.getControlTextFont();}
  616.     public static FontUIResource getSystemTextFont() { return currentTheme.getSystemTextFont();}
  617.     public static FontUIResource getUserTextFont() { return currentTheme.getUserTextFont();}
  618.     public static FontUIResource getMenuTextFont() { return currentTheme.getMenuTextFont();}
  619.     public static FontUIResource getWindowTitleFont() { return currentTheme.getWindowTitleFont();}
  620.     public static FontUIResource getSubTextFont() { return currentTheme.getSubTextFont();}
  621.  
  622.     public static ColorUIResource getDesktopColor() { return currentTheme.getDesktopColor(); }
  623.     public static ColorUIResource getFocusColor() { return currentTheme.getFocusColor(); }
  624.  
  625.     public static ColorUIResource getWhite() { return currentTheme.getWhite(); }
  626.     public static ColorUIResource getBlack() { return currentTheme.getBlack(); }
  627.     public static ColorUIResource getControl() { return currentTheme.getControl(); }
  628.     public static ColorUIResource getControlShadow() { return currentTheme.getControlShadow(); }
  629.     public static ColorUIResource getControlDarkShadow() { return currentTheme.getControlDarkShadow(); }
  630.     public static ColorUIResource getControlInfo() { return currentTheme.getControlInfo(); } 
  631.     public static ColorUIResource getControlHighlight() { return currentTheme.getControlHighlight(); }
  632.     public static ColorUIResource getControlDisabled() { return currentTheme.getControlDisabled(); }
  633.  
  634.     public static ColorUIResource getPrimaryControl() { return currentTheme.getPrimaryControl(); }  
  635.     public static ColorUIResource getPrimaryControlShadow() { return currentTheme.getPrimaryControlShadow(); }  
  636.     public static ColorUIResource getPrimaryControlDarkShadow() { return currentTheme.getPrimaryControlDarkShadow(); }  
  637.     public static ColorUIResource getPrimaryControlInfo() { return currentTheme.getPrimaryControlInfo(); } 
  638.     public static ColorUIResource getPrimaryControlHighlight() { return currentTheme.getPrimaryControlHighlight(); }  
  639.  
  640.     public static ColorUIResource getSystemTextColor() { return currentTheme.getSystemTextColor(); }
  641.     public static ColorUIResource getControlTextColor() { return currentTheme.getControlTextColor(); }  
  642.     public static ColorUIResource getInactiveControlTextColor() { return currentTheme.getInactiveControlTextColor(); }  
  643.     public static ColorUIResource getInactiveSystemTextColor() { return currentTheme.getInactiveSystemTextColor(); }
  644.     public static ColorUIResource getUserTextColor() { return currentTheme.getUserTextColor(); }
  645.     public static ColorUIResource getTextHighlightColor() { return currentTheme.getTextHighlightColor(); }
  646.     public static ColorUIResource getHighlightedTextColor() { return currentTheme.getHighlightedTextColor(); }
  647.  
  648.     public static ColorUIResource getWindowBackground() { return currentTheme.getWindowBackground(); }
  649.     public static ColorUIResource getWindowTitleBackground() { return currentTheme.getWindowTitleBackground(); }
  650.     public static ColorUIResource getWindowTitleForeground() { return currentTheme.getWindowTitleForeground(); }
  651.     public static ColorUIResource getWindowTitleInactiveBackground() { return currentTheme.getWindowTitleInactiveBackground(); }
  652.     public static ColorUIResource getWindowTitleInactiveForeground() { return currentTheme.getWindowTitleInactiveForeground(); }
  653.  
  654.     public static ColorUIResource getMenuBackground() { return currentTheme.getMenuBackground(); }
  655.     public static ColorUIResource getMenuForeground() { return currentTheme.getMenuForeground(); }
  656.     public static ColorUIResource getMenuSelectedBackground() { return currentTheme.getMenuSelectedBackground(); }
  657.     public static ColorUIResource getMenuSelectedForeground() { return currentTheme.getMenuSelectedForeground(); }
  658.     public static ColorUIResource getMenuDisabledForeground() { return currentTheme.getMenuDisabledForeground(); }
  659.     public static ColorUIResource getSeparatorBackground() { return currentTheme.getSeparatorBackground(); }
  660.     public static ColorUIResource getSeparatorForeground() { return currentTheme.getSeparatorForeground(); }
  661.     public static ColorUIResource getAcceleratorForeground() { return currentTheme.getAcceleratorForeground(); }
  662.     public static ColorUIResource getAcceleratorSelectedForeground() { return currentTheme.getAcceleratorSelectedForeground(); }
  663.  
  664. }
  665.